package com.fosdata.dpm.interceptor;


import com.fosdata.dpm.domain.SysUser;
import com.fosdata.dpm.exception.AuthFailedException;
import com.fosdata.dpm.services.SysUserServices;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;



/**
 * 登录状态判断
 */
@Component
public class AuthInterceptor implements HandlerInterceptor {

    private static final Logger LOG = LoggerFactory.getLogger(AuthInterceptor.class);

    @Autowired
    private SysUserServices userServices;

    @Override
    public boolean preHandle(HttpServletRequest request,
                             HttpServletResponse response,
                             Object handler)
            throws AuthFailedException, NotAssignPermissionException {

        String captpa = request.getHeader("token");
        if (StringUtils.isBlank(captpa)) {
            throw new AuthFailedException("验证失败");
        }
        return true;
    }




}
